<template>
    <div>
<h1>会员信息显示</h1>


会员账号:<input type="text" v-model="nadio" placeholder="请输入账号">
性别:<select v-model="das">
    <option value="0">请选择</option>
    <option value="2">男</option>
    <option value="1">女</option>
</select>

<input type="button"  value="查询" class="btn btn-success" @click="yz">
<table class="table table-bordered" border="1">
  <thead>
    <tr>
        <td>会员编号</td>
        <td>会员名称</td>
        <td>性别</td>
        <td>手机号码</td>
        <td>身份证</td>
        <td>会员级别</td>
        <td>状态</td>
        <td>积分</td>
        <td>余额</td>
        <td>时间</td>
        <td>操作</td>
    </tr>
  </thead>
  <tbody>
    <tr v-for="item in xs">
        <td>{{item.guid}}</td>
        <td>{{item.name}}</td>
        <td>{{item.xb==true?'男':'女'}}</td>
        <td>{{item.hoam}}</td>
        <td>{{item.sfz}}</td>
        <td>{{item.yname}}</td>
        <td>{{item.zt==true?'良好':'冻结'}}</td>
        <td>{{item.jf}}</td>
        <td>{{item.yue}}</td>
        <td>{{item.date}}</td>
        <td><a href="#" @click="sc(item.id)" style="margin-right: 10px;">删除</a>
            <a href="#" @click="xg(item.id)" >修改</a></td>
    </tr>
  </tbody>
</table>

    </div>
</template>

<script setup lang="ts">
import axios from "axios";
import {ref,onMounted  } from "vue";
import { useRouter } from "vue-router";
useRouter

const reds = useRouter();

const nadio = ref("");
const das = ref(0);

onMounted(()=>{

    yz();
})



const xs =ref([{

    id:0,
    guid: "",
    name: "",
    xb: false,
    hoam: "",
    sfz: "",
    yname: 0,
    zt: false,
    jf: 0,
    yue: 0,
    date: ""


}]);


const yz =()=>{

axios.get('https://localhost:7268/api/hy/showmember',{

params:{

    name:nadio.value,
    xb:das.value
}

})

.then(res=>{
xs.value=res.data;
})
.catch(error=>{

    console.log(error);

})




}


const sc=(kkid:number)=>{
    if(confirm('确认删除吗'))
    {

        axios.delete('https://localhost:7268/api/hy/sclist',{

      params:{

        id:kkid

        }
         
        
       })
       .then(res=>{
         
    if(res.data>0)
    {

        alert('删除成功');
    }
    else{

        alert('删除失败');
    }


       })
    .catch(error=>{

     console.log(error);

    })


    }


}

const xg=(id:number)=>{

    reds.push({
    name:"hyxg",
    params:{

        id:id

    }


    });

    
}

</script>

<style scoped>

</style>